package com.itheima.d02_xml;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

/**
 *
 */
public class Tset {
    public static void main(String[] args) throws DocumentException {
        //1.创建XML解析器SaxReader
        SAXReader saxReader = new SAXReader();


        //2.使用解析器对象把xml文件读取成一个Document对象
        Document doc = saxReader.read("E:\\soft_install\\ideaIU\\JavaProject\\day12_properties\\src\\com\\itheima\\d02_xml\\users.xml");

        //3.解析操作
        //3.1 获取根元素对象
        Element root = doc.getRootElement();//Elment 元素对象 == 一对标签
        System.out.println("标签名称："+root.getName());


        List<Element>elements = root.elements();
        //System.out.println(root.element(root.getName()));
        for (Element element : elements){
            System.out.println("标签名称："+element.getName());
        }

        System.out.println("===========");
        Element catElement = root.element("cat");




    }
}
